<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>新增发票</title>
<link rel="stylesheet" href="../static/main/css/styles.css">
<link rel="stylesheet" type="text/css"
	href="../static/jquery-ui-themes-1.10.4/themes/ui-darkness/jquery.ui.theme.css">
<link rel="stylesheet" type="text/css"
	href="../static/jquery-ui-themes-1.10.4/themes/ui-darkness/jquery-ui.css">
<link rel="stylesheet"
	href="../webjars/bootstrap/3.3.7-1/css/bootstrap.css">
<link rel="stylesheet" type="text/css"
	href="../static/jqgrid/css/ui.jqgrid.css">
<script type="text/javascript"
	src="../static/jqgrid/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript"
	src="../webjars/bootstrap/3.3.7-1/js/bootstrap.js"></script>
<script type="text/javascript"
	src="../static/jqgrid/js/jquery.jqGrid.min.js"></script>
<script type="text/javascript" src="../static/laydate/laydate.js"></script>
<script type="text/javascript" src="../static/jqgrid/js/jquery-ui.js"></script>
<script type="text/javascript"
	src="../static/jqgrid/js/grid.locale-cn.js"></script>

<script type="text/javascript">
$(function(){
	$('#list1').jqGrid({
		url: 'list',
		editurl:'edit',
		caption:'用户列表', 
		altRow:true,
		autowidth:true,
		width:'100%',
		/* height:'100%', */
		datatype:'json',
		mtype:'post',
		PageSize: 15,
		rowNum:10,
		postData:{classId:[[${classId}]]},
		rowList : [5 , 10, 35, 100 ],
		prmNames:{search:'search'},
		sortname:'id',
		viewrecords:true,
		pager:'#dhl',
		jsonReader:{
			repeatitems:false,
			id:'id'
		},
		colModel:[
			//{name:'id',label:'编号',index:'id',align:'center',width:'60',sorttype:'int'},
			{name:'name',label:'报销人',index:'name',align:'center',width:'100',sorttype:'text',editable:true,editrules:{required: true}},
			{name:'invoice_code',label:'发票代码',index:'invoice_code',align:'center',sorttype:'text',editable:true,editrules:{required: true}},
			{name:'invoice',label:'发票号码',index:'invoice',align:'center',sorttype:'text',editable:true,editrules:{required: true}},
			{name:'date_open',label:'开票日期',index:'date_open',search:false,align:'center',formatter:"date",editrules:{required: true,date:true}, formatoptions: {newformat:'Y-m-d'},align:'center',width:100,sorttype:'text',editable:true
					,editoptions:{
		                dataInit:function(e){
		                laydate.render({
                			elem: e //指定元素
	                	});
	                
	                 	 /* $(e).datepicker({
	                        language:"zh-CN",//语言
	                        autoclose: true,//自动关闭
	                        todayBtn: "linked",//
	                        format: "yyyy-mm-dd"//时间显示格式
	                    }); */
	                    $(this).click(function(e){//选中时间后隐藏
	                        $(e).parent().datepicker('hide');
	                    });
	                }
	            },sortable : false},
			{name:'bursement_time',label:'报销时间',index:'bursement_time',search:false,align:'center',formatter:"date",editrules:{required: true,date:true}, formatoptions: {newformat:'Y-m-d'},align:'center',width:100,sorttype:'text',editable:true,editoptions:{
	                dataInit:function(e){
	                laydate.render({
                		  elem: e //指定元素
                		});
	                
	                  /*   $(e).datepicker({
	                        language:"zh-CN",//语言
	                        autoclose: true,//自动关闭
	                        todayBtn: "linked",//
	                        format: "yyyy-mm-dd"//时间显示格式
	                    }); */
	                    $(this).click(function(e){//选中时间后隐藏
	                        $(e).parent().datepicker('hide');
	                    });
	                }
	            },sortable : false},
			//{name:'kpdw',label:'开票单位',index:'kpdw',align:'center',sorttype:'text',editable:true,editrules:{required: true}},
			{name:'money',label:'金额',index:'money',align:'center',width:'100',sorttype:'text',editable:true,editrules:{required: true,number:true//,custom_func: ValidateTmoney 
				}}
		]
		
	});
	
	 function ValidateTmoney(value,name){
		 var regu = "^[0-9]+(.[0-9]{2})?$";
        //var regu = "/^\+?(\d*\.\d{2})$/";
        var re = new RegExp(regu);
		if(!(re.test(value))){
			 return [false, "请输入数字"]; 
        }else{
            return [true,""];
          }  
	} 
 /* 	 $('#list1').jqGrid(options); */
	$('#list1').jqGrid('navGrid', '#dhl', {
		  //refresh:false,//刷新
		  //search:false,//搜索
			edit : true,
			add : true,
			del : true,
			view : true, 
			 searchtext:'查找',edittext:'编辑',addtext:'添加',refreshtext:'刷新', deltext:'删除',
		}, {
			top:204,
			left:453,
			beforeSubmit: function(postdata,formid){
				postdata['kpdw.id']=$('#dwSel').val();
				return [true,'OK!'];
			},
			closeAfterEdit:true,
			closeOnEscape:true,
			savekey:[true,13]
			
		}, {
			top:204,
			left:453,
			beforeSubmit: function(postdata,formid){
				postdata.id='',
				postdata['kpdw.id']=$('#dwSel').val();
				return [true,'OK!'];
			},
			closeAfterAdd:true,
			closeOnEscape:true,
			savekey:[true,13]
		}, {
			top:204,
			left:453,
			closeOnEscape:true
		},{
			left:453,
			top:204,
			closeAfterSearch:true,
			closeAftreReset:true,
			closeOnEscape:true,
			multipleSearch:true
		}
		);

	});
	
function bjChange(classId){
	var postdata={classId:classId};
	options.postData=postdata;
	$("#list1").setGridParam(options).trigger("reloadGrid");
}

</script>
<style type="text/css">
.neirong {
	margin: 0;
	padding-left: 15%;
	padding-right: 15%;
}

.ui-pg-input {
	background: #999;
	color: #000;
	text-align: center;
	font-size: 20px;
	font-weight: 1000;
}

.ui-pg-selbox {
	background: #999;
	color: #000;
	font-weight: 1000;
}

.ui-pg-selbox option {
	font-weight: 1000;
}

.add-rule ui-add {
	color: black;
}

#fa {
	margin: 0;
	padding: 0 5px;
	font-weight: 1000;
	font-size: 25px;
}

select {
	background: #999;
	color: #000;
}

option {
	background: #999;
	color: #000;
}

.add-rule ui-add {
	color: #000;
}

input[type="button"] {
	color: #000;
}
</style>

</head>
<body>
	<div class="caidan">
		<div class="htmleaf-container">
			<nav class="animenu">
				<ul class="animenu__nav"
					style="margin-left: 15%; margin-right: 15%;">
					<li style="font-size: 20px; font-weight: 1100;"><a id="fa">发票管理系统</a></li>
					<li><a href="../main"><span
							class="glyphicon glyphicon-home">首页</span></a></li>
					<li><a>欢迎您:<span sec:authorize="hasRole('ROLE_DBA')">>开发者</span><span
							sec:authorize="!hasRole('ROLE_DBA')"
							sec:authentication="principal.name">张三</span></a></li>
					<li sec:authorize="hasRole('ROLE_MANAGER')"><a
						href="../UserTenant/zuhugl"><span
							class="glyphicon glyphicon-pencil">租户编辑</span></a></li>
					<li sec:authorize="hasRole('ROLE_ADMIN')"><a
						href="../UserManager/xzgl"><span
							class="glyphicon glyphicon-pencil">用户编辑</span></a></li>
					<li sec:authorize="hasRole('ROLE_ZUHU')"><a
						href="../User/xzgl"><span class="glyphicon glyphicon-pencil">用户管理</span></a></li>
					<li sec:authorize="hasRole('ROLE_MANAGER')"><a
						href="../UserManager/fpcx">电子发票查询</a></li>
					<li sec:authorize="hasRole('ROLE_MANAGER')"><a
						href="../UserManager/sqxx">软件授权信息</a>
					<li sec:authorize="hasRole('ROLE_ZUHU')"><a
						href="../Tenantxx/zxfp">新增电子发票信息</a></li>
					<li sec:authorize="hasRole('ROLE_ADMIN')"><a
						href="../SysUser/yhcz">用户操作日志</a></li>
					<li sec:authorize="hasRole('ROLE_ZUHU')"><a
						href="../UserTenant/xgmm"><span
							class="glyphicon glyphicon-tags">&nbsp;修改密码</span></a></li>
					<li sec:authorize="hasRole('ROLE_MANAGER')"><a
						href="../UserManager/xgmm"><span
							class="glyphicon glyphicon-tags">&nbsp;修改密码</span></a></li>
					<li sec:authorize="hasRole('ROLE_ADMIN')"><a
						href="../SysUser/xgmm"><span class="glyphicon glyphicon-tags">&nbsp;修改密码</span></a></li>
					<li style="float: right;"><a href="../logout"><span
							class="glyphicon glyphicon-off">注销</span></a></li>
				</ul>
			</nav>
		</div>
	</div>

	<div class="neirong">
		<p class="ui-widget ui-widget-content"
			style="padding-left: 1em; margin-bottom: 0;">
			<span>开票单位：</span> <select onchange="dwChange(this.value)" id="dwSel"
				style="border: 1px #888 solid;">
				<option style="background: #999; color: #000;"
					th:each="dw : ${findAll}" th:value="${dw.id}"
					th:text="${dw.beizhu}">单位</option>
			</select>
		</p>
		<table id="list1"></table>
		<div id="dhl"></div>
	</div>
</body>
</html>